import {showToast, showToastSuccess} from "../../../../../utils/tool";
import {simplePost} from "../../../../../utils/request";




const app = getApp()

Component({
    options:{
        styleIsolation: 'apply-shared',
    },
    properties: {
        orderRefund: Object,
    },

    data: {
        show: false,
        subLoading:false,
        expresses:null,
        post:{
            // express_id:'',
        }
    },

    attached() {

    },

    methods: {
        /**
         * 弹窗显示
         */
        open: function () {
            this.setData({
                show: true,
                subLoading: false,
            })
        },

        // expressChange(e){
        //     const {value} = e.detail
        //     this.setData({
        //         [`post.express_id`]:value,
        //     })
        // },

        submit: function (e) {
            const {orderRefund} = this.data
            const form = e.detail.value;//表单提交参数


            // if (!post.express_id) {
            //     showToast("必须选择快递公司")
            //     return;
            // }

            if (!form.express_order_no) {
                showToast('必须填写快递单号')
                return;
            }


            this.setData({
                subLoading: true,
            })

            // 确认发货
            simplePost('/orderRefund/delivery', {
                id:orderRefund.id,
                express_order_no:form.express_order_no,
            }).then(r => {
                showToastSuccess("操作成功")
                this.setData({
                    show:false
                })
            }).catch(err => {
                this.setData({
                    subLoading: false,
                })
            })
        }
    }

})
